package com.liuqi.openai.core.chat;

/**
 * 消息角色
 *
 * @author liuqi
 * @date 2025/7/18
 **/
public enum Role {

    SYSTEM("system"),

    USER("user"),

    ASSISTANT("assistant"),

    TOOL("tool"),

    FUNCTION("function");

    private final String stringValue;

    Role(String stringValue) {
        this.stringValue = stringValue;
    }

    @Override
    public String toString() {
        return stringValue;
    }

    public static Role from(String stringValue) {
        for (Role role : Role.values()) {
            if (role.stringValue.equals(stringValue)) {
                return role;
            }
        }
        throw new IllegalArgumentException("Unknown role: '" + stringValue + "'");
    }

}
